<?php
/**
 * Free Uch
 *
 * @category   FreeUch
 * @copyright  Copyright 2009 lordharrdlee(http://www.lordharrdlee.cn)
 * @author     lordharrdlee<lordharrdlee@gmail.com>
 * @version    $Id: ZendDB.php 10 2010-01-14 10:31:01Z lordharrdlee $
 */
/**
 * make Zend_Db mysql PDO
 *
 * @author  liyizhou<lordharrdlee@hotmail.com>
 */
class Db_ZendDB
{

    /**
     * @var Zend_Db_Adapter_Abstract
     */
    private static $_instance;

    /**
     * @return Zend_Db_Adapter_Abstract
     */
    static public function getInstance()
    {
        global $_SC;
        if (! self::$_instance instanceof Zend_Db_Adapter_Abstract) {
            $dbconfig = array(
                'host' => $_SC['dbhost'],
                'dbname' => $_SC['dbname'],
                'username' => $_SC['dbuser'],
                'password' => $_SC['dbpw'],
                'charset' => $_SC['dbcharset'],
                'prefix' => $_SC['tablepre'],
                'driver_options' => array(
                    PDO::MYSQL_ATTR_INIT_COMMAND => 'set names "' . $_SC['dbcharset'] . '"'
                )
            );
            self::$_instance = Zend_Db::factory('PDO_MYSQL', $dbconfig);
        }
        return self::$_instance;
    }
}
?>